package util;

import java.util.Map;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;

public class MessageUtil implements Delayed{
	
	private int id;    
    private String body;  //��Ϣ����  
    private Map bodyMap;
    private long excuteTime;//ִ��ʱ��   

	public Map getBodyMap() {
		return bodyMap;
	}

	public void setBodyMap(Map bodyMap) {
		this.bodyMap = bodyMap;
	}

	public int getId() {  
        return id;  
    }  
  
    public void setId(int id) {  
        this.id = id;  
    }  
  
    public String getBody() {  
        return body;  
    }  
  
    public void setBody(String body) {  
        this.body = body;  
    }  
  
    public long getExcuteTime() {  
        return excuteTime;  
    }  
  
    public void setExcuteTime(long excuteTime) {  
        this.excuteTime = excuteTime;  
    }  
  
    public MessageUtil(String body,long delayTime) {    
        this.body = body;    
        this.excuteTime = TimeUnit.NANOSECONDS.convert(delayTime, TimeUnit.MILLISECONDS) + System.nanoTime();    
    }   
    
    public MessageUtil(Map map,long delayTime) {    
        this.bodyMap = map;    
        this.excuteTime = TimeUnit.NANOSECONDS.convert(delayTime, TimeUnit.MILLISECONDS) + System.nanoTime();    
    }  
    
    public long getDelay(TimeUnit unit) {  
        return  unit.convert(this.excuteTime - System.nanoTime(), TimeUnit.NANOSECONDS);     
    }  

	public int compareTo(Delayed o) {
		return 0;
	}
}
